<?php

class PortableContact
{
 // public myspaceContext
   
    public $context = NULL;
  
  /**
   * Sets up the Real Time Stream with MySpace Context
   *
   * @param MySpaceContext $context
   * @return object a new real time stream object
   */
    
   public function __construct($context)  {
     $this->context = $context;
   }
   
  /**
   * Portable contacts call to get person.  
   * @param string $fields Fields to retrieve
   * @return Person being fetched
   */
  public function getPersonPoco($personId, $fields = null) {
  	$REST = 'http://api.myspace.com/v2/people/'.$personId.'/@self?';

  	$params = array('format'=>'json', 'fields'=>'@all', 'fields'=>$fields);
  	$responseJSON = $this->context->call($REST, $params, 'GET');

  	return MySpaceUtils::parseJSON($responseJSON);
  }
  
  
  /**
   * Portable contacts call to get friends.  
   * @param string $startIndex First item to retrieve; defaults to 1 if not given
   * @param string $count Numer of items to retrieve; defaults to 10 if not given
   * @return Friends being fetched
   */
  public function getFriendsPoco($personId, $startIndex = 1, $count = 10) {
  	$REST = 'http://api.myspace.com/v2/people/'.$personId.'/@friends';

    $params = array('format'=>'json', 'startIndex'=>$startIndex, 'count'=>$count);
  	$responseJSON = $this->context->call($REST, $params, 'GET');

  	return MySpaceUtils::parseJSON($responseJSON);
  }
}

?>